Skip to content

Conversation

@krlls
Copy link

@krlls krlls commented Nov 11, 2024

Hi!

I’ve added a mouseMode prop that allows controlling the method of item selection with a mouse. Now, you can select an item either by clicking or by dragging, depending on the set value.

  • Introduced the mouseMode prop with values 'click' and 'drag'.
  • When set to 'click', the item will be selected by a mouse click as is currently implemented.
  • When set to 'drag', the item will be selected by dragging, similar to mobile behavior
import { useState } from 'react'
import Picker from 'react-mobile-picker'

function MyPicker() {
  const [pickerValue, setPickerValue] = useState({
    name1: 'item1',
    /* ... */
  })

  return (
    <Picker value={pickerValue} onChange={setPickerValue} mouseMode="drag">
      {/* ... */}
    </Picker>
  )
}

- Added the `mouseMode` prop to control item selection behavior.
- If set to 'click', item selection will happen by clicking.
- If set to 'drag', item selection will happen by dragging (similar to mobile behavior).
@vercel
Copy link

vercel bot commented Nov 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-mobile-picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 8:27pm

@bharatgidwani
Copy link

I am still facing this issue. Is this merged?

@adcentury
Copy link
Owner

Hi, @krlls , thanks for the PR. I don't see the use cases for this feature right now. If you use this component in "mobile mode" (you can toggle it using chrome devtool), you can drag n drop the item to select it. This is how it was designed to behave. So IMO there is already a "drag" mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants